<?php 
include_once(dirname(__FILE__)."/conn.php"); 

$page=isset($_GET["page"])?$_GET["page"]:1;

$pagesize=20;
$fromid=($page-1)*$pagesize;
$sql="SELECT openid FROM usercharacter group by openid ORDER BY `buytime` DESC LIMIT {$fromid},{$pagesize}";
$sql1="SELECT COUNT(*) AS `c` FROM usercharacter group by openid";

$userlist=$db->getRows($sql);
$nownum = count($userlist);

$totalRow=$db->getRow($sql1);
$total=$totalRow["c"];
$isspage_str=isspage($total,$nownum,$pagesize,$page,"user_list.php","");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>用户列表</title>
<link rel="stylesheet" type="text/css" href="base.css">
<base target="_self">
<style type="text/css">
<!--
.STYLE1 {color: #333333}
.STYLE2 {
	color: #2C73DE;
	font-weight: bold;
}
-->
</style>
<script language="javascript">
function delArc(aid){
	var qstr=getCheckboxItem();
	location="user_del.php?qstr="+qstr;
}

//获得选中文件的文件名
function getCheckboxItem()
{
	var allSel="";
	if(document.form2.arcID.value) return document.form2.arcID.value;
	for(i=0;i<document.form2.arcID.length;i++)
	{
		if(document.form2.arcID[i].checked)
		{
			if(allSel=="")
				allSel=document.form2.arcID[i].value;
			else
				allSel=allSel+"`"+document.form2.arcID[i].value;
		}
	}
	return allSel;	
}

//获得选中其中一个的id
function getOneItem()
{
	var allSel="";
	if(document.form2.arcID.value) return document.form2.arcID.value;
	for(i=0;i<document.form2.arcID.length;i++)
	{
		if(document.form2.arcID[i].checked)
		{
				allSel = document.form2.arcID[i].value;
				break;
		}
	}
	return allSel;	
}

function selAll()
{
	if(!document.form2.arcID.checked)
	{
		document.form2.arcID.checked=true;
	}
	for(i=0;i<document.form2.arcID.length;i++)
	{
		if(!document.form2.arcID[i].checked)
		{
			document.form2.arcID[i].checked=true;
		}
	}
}
function noSelAll()
{
	if(document.form2.arcID.checked)
	{
		document.form2.arcID.checked=false;
	}
	for(i=0;i<document.form2.arcID.length;i++)
	{
		if(document.form2.arcID[i].checked)
		{
			document.form2.arcID[i].checked=false;
		}
	}
}
</script>
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body leftmargin="8" topmargin="8" background='img/allbg.gif'>
<table width='98%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr> 
<td align='center' valign='top'>
	<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#98CAEF">
		<tr> 
    <td height="26" background="img/wbg.gif">
    <table width="98%" border="0" cellspacing="0" cellpadding="0">
     <tr> 
     <td align="center">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;按openid查找:
  <input type='text' id="search_openid" name="search_openid">
  <input type='button' onClick="location='user_edit.php?id='+document.getElementById('search_openid').value;" value='搜索' class='nbt'>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

</td>
     </tr>
    </table>
    </td>
    </tr>
  </table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#FFFFFF"><td height="4"></td></tr>
</table>
<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#98CAEF">
<tr bgcolor="#E7E7E7"> 
<td height="24" colspan="10" background="img/tbg.gif">
	§用户列表&nbsp;</td>
</tr>
<form name="form2">
<tr align="center" bgcolor="#F8FBFB" height="22"> 
<td width="5%"></td>
<td width="15%" align="center">用户编号</td>
<td width="10%" align="left">昵称</td>
<td width="7%" align="left">当前金币数</td>
<td width="7%" align="left">当前生命数</td>
<td width="6%" align="left">当前总钻石数</td>
<td width="15%" align="left">当前总积分</td>
<td width="15%" align="left">上次登录时间</td>
<td width="10%" align="left">登录总天数</td>
<td width="10%">操作</td>
</tr>
<?php 
$userClass = new user_user();
foreach($userlist as $user){
	try{
		$userInfo = $userClass->getUserInfo($user["openid"]);
	}catch(Exception $e){
		$userInfo = null;
	}
?>
<tr align='center' bgcolor="#FFFFFF"  onMouseMove="javascript:this.bgColor='#EFEFEF';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22"> 
<td align='center'><input name="arcID" type="checkbox" id="arcID" value="<?php echo $user['openid']?>" class="np"></td>
<td align='center'><?php echo $user['openid']?></td>
<td align='left'><?php echo $userInfo?$userInfo['nickname']:""?></td>
<td align='left'><?php echo $userInfo?$userInfo['goldnum']:""?></td>
<td align='left'><?php echo $userInfo?$userInfo['lifereserve']:""?></td>
<td align='left'><?php echo $userInfo?$userInfo['diamondnum']:""?></td>
<td align='left'><?php echo $userInfo?$userInfo['scorenum']:""?></td>
<td align='left'><?php echo $userInfo?$userInfo['lastlogintime']:""?></td>
<td align='left'><?php echo $userInfo?$userInfo['logindates']:""?></td>
<td>
 <a href="user_edit.php?id=<?php echo $user['openid']?>">编辑</a>&nbsp;
 <a href="user_del.php?qstr=<?php echo $user['openid']?>">删除</a>
 
 </td>
</tr>
<?php 
}
?>
</form>
<tr bgcolor="#F8FBFB"> 
<td height="24" colspan="11">
&nbsp;
<a href="javascript:selAll()" class="coolbg">全选</a> 
<a href="javascript:noSelAll()" class="coolbg">取消</a> &nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;
<a href="javascript:delArc(0)" class="coolbg">&nbsp;删除&nbsp;</a></td>
</tr>
</form>
<tr align="right" bgcolor="#E5F9FF"> 
<td height="20" colspan="11" align="center">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="right"><?php echo $isspage_str["str1"];?></td>
    <form method="GET" class="issPage"><td align="left" valign="middle"><?php echo $isspage_str["str2"];?></td></form>
  </tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>